package com.sharemarking.wa.platform.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sharemarking.wa.common.entity.Org;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


/**
 * @author dxy
 */
@Repository
public interface OrgMapper extends BaseMapper<Org> {
    @Select("SELECT IFNULL(b.name,a.name) FROM sys_org a LEFT JOIN wa_org_verify b ON a.id = b.org_id WHERE a.id = #{id}")
    String getOrgNameById(Integer id);

    @Select("SELECT a.is_monthly_pay FROM sys_org a LEFT JOIN sys_org_member b ON a.id = b.org_id WHERE b.member_id = #{memberId}")
    Integer isOrgMonthPay(Integer memberId);

    @Update("UPDATE sys_org SET real_name = null WHERE id = #{memberId}")
    void updateRealNameNull(Integer memberId);

    @Select("select id from sys_org where member_id = #{memberId}")
    Integer selectOrdId(Integer memberId);


    @Select("select real_name from sys_org where id = #{orgId}")
    String getRealName(Integer orgId);
}
